// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Music Event Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// Aliases
private alias 4 : TYPE_MUSICEVENT


// Static Values

// Tables

event ObjectMain
	switch object.propertyValue
	case 0
		if vs.bossAttack == 0
			object.propertyValue = 3
		else
			if music.currentTrack == 4
				object.type = TypeName[Blank Object]
			else
				object.propertyValue = 3
			endif
				
		end if
		break
	case 1
		if vs.bossAttack == 0
			object.propertyValue = 4
			if stage.activeList == BONUS_STAGE
				if stage.listPos >= 0
					vs.bossAttack = 1
					object.type = TypeName[Blank Object]
				end if
			end if
		else
			object.type = TypeName[Blank Object]
		end if
		break
	case 2
		if object.value0 < 240
			if music.volume > 0
				PauseMusic()
				music.volume = 0
			end if
			object.value0++
		else
			if music.volume == 0
				ResumeMusic()
				switch stage.musicFlag
				case 1
					CallFunction(SpeedUpMusic)
					stage.musicFlag = 0
					break
				case 2
					CallFunction(SlowDownMusic)
					stage.musicFlag = 0
					break
				end switch
				music.volume = 5
			else
				if music.volume < 100
					music.volume += 5
				else
					object.type = TypeName[Blank Object]
				end if
			end if
		end if
		break
	case 3
		if object.value0 < 50
			object.value0++
			music.volume -= 2
		else
			PlayMusic(4)
			object.type = TypeName[Blank Object]
		end if
		break
	case 4
		if object.value0 < 50
			object.value0++
			music.volume -= 2
		else
			PlayMusic(0)
			object.type = TypeName[Blank Object]
		end if
		break
	case 5
		if music.currentTrack != 8
			if object.value0 < 50
				object.value0++
				music.volume -= 2
			else
				PlayMusic(8)
				object.type = TypeName[Blank Object]
			end if
		endif
		break
	end switch
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
